home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d15 / infop141.arc / PAGE_17.PAS < prev    next >
Pascal/Delphi Source File  |  1990-12-07  |  5KB  |  162 lines

  1. procedure page_17;
  2.   const
  3.     DayName: array[0..7] of string[9] = ('Sunday', 'Monday', 'Tuesday',
  4.                                          'Wednesday', 'Thursday', 'Friday',
  5.                                          'Saturday', 'Sunday');
  6.     MonthName: array[0..12] of string[9] = ('???', 'January', 'February', 'March',
  7.                                             'April', 'May', 'June', 'July',
  8.                                             'August', 'September', 'October',
  9.                                             'November', 'December');
  10.     ScreenName: array[0..3] of string[10] = ('EGA/VGA', 'CGA 40col',
  11.                                                  'CGA 80col', 'Monochrome');
  12.     FloppyName: array[0..5] of string[11] = ('none', '5.25" 360K',
  13.                                              '5.25" 1.2M', '3.5"  720K',
  14.                                              '3.5"  1.44M', '3.5"  2.88M');
  15.  
  16.   var
  17.     CMOSport: word;
  18.     count, checksum1, checksum2: word;
  19.     bad, pm: boolean;
  20.     floppy, hd, hdc, hdd, date, month, century, year, hour, min, sec: byte;
  21.     c: char;
  22.  
  23.   function readCMOS(adr: byte): byte;
  24.     var
  25.       i: byte;
  26.  
  27.     begin
  28.     bad:=false;
  29.     if CMOSport = $70 then
  30.       begin
  31.       inline($FA);
  32.       Port[CMOSport]:=adr;
  33.       for i:=1 to 10 do;
  34.       readCMOS:=Port[CMOSport + 1];
  35.       inline($FB)
  36.       end
  37.     else
  38.       begin
  39.       inline($FA);
  40.       i:=Port[CMOSport + adr];
  41.       if i <> Port[CMOSport + adr] then
  42.         bad:=true;
  43.       inline($FB);
  44.       readCMOS:=i
  45.       end
  46.     end; {readCMOS}
  47.  
  48.   function addzero(b: byte): string;
  49.     var
  50.       c2: string[2];
  51.     begin
  52.     Str(b:0, c2);
  53.     if b < 10 then
  54.       c2:='0' + c2;
  55.     addzero:=c2
  56.     end; {addzero}
  57.  
  58.   function unBCD(b: byte): byte;
  59.     begin
  60.     unBCD:=(b and $0F) + ((b shr 4) * 10)
  61.     end; {unBCD}
  62.  
  63.   begin
  64.   caption2('CMOS');
  65.   regs.AH:=$C0;
  66.   Intr($15, regs);
  67.   if nocarry or (Mem[$F000:$FFFE] = $FC) then
  68.     begin
  69.     CMOSport:=$70;
  70.     Writeln;
  71.     caption3('Date');
  72.     date:=unBCD(readCMOS(7));
  73.     century:=unBCD(readCMOS($32));
  74.     year:=unBCD(readCMOS(9));
  75.     month:=unBCD(readCMOS(8));
  76. { Most BIOS's do not set the Day of Week byte. Commented out and left for info}
  77. {    Write(DayName[readCMOS(6)], ', ');}
  78.     case country[0] of
  79.       0, 3..255: Writeln(Monthname[month], ' ', date, ', ', century, addzero(year));
  80.       1: Writeln(date, ' ', Monthname[month], ', ', century, addzero(year));
  81.       2: Writeln(century, addzero(year), ', ', Monthname[month], ' ', date);
  82.     end; {case}
  83.     caption3('Time');
  84.     c:=Chr(country[$0D]);
  85.     hour:=unBCD(readCMOS(4));
  86.     min:=unBCD(readCMOS(2));
  87.     sec:=unBCD(readCMOS(0));
  88.     if country[$11] and 1 = 1 then
  89.       Writeln(hour, c, addzero(min), c, addzero(sec))
  90.     else
  91.       begin
  92.       pm:=false;
  93.       case hour of
  94.         0: hour:=12;
  95.         1..11: hour:=hour;
  96.         12: pm:=true;
  97.         13..23: begin
  98.                 pm:=true;
  99.                 hour:=hour - 12
  100.                 end;
  101.       end; {case}
  102.       Write(hour, c, addzero(min), c, addzero(sec), ' ');
  103.       if pm then
  104.         Writeln('PM')
  105.       else
  106.         Writeln('AM');
  107.       end;
  108.     Writeln;
  109.     caption3('Video type ');
  110.     Writeln(ScreenName[(readCMOS($14) shr 4) and 3]);
  111.     caption3('Coprocessor');
  112.     yesorno((readCMOS($14) and 2) = 2);
  113.     Writeln;
  114.     caption3('Floppy disk A');
  115.     floppy:=readCMOS($10);
  116.     if (floppy shr 4) < 5 then
  117.       Writeln(FloppyName[floppy shr 4])
  118.     else
  119.       Writeln('Unknown value -> ', hex(floppy shr 4, 2));
  120.     caption3('Floppy disk B');
  121.     if (floppy and $0F) < 5 then
  122.       Writeln(FloppyName[floppy and $0F])
  123.     else
  124.       Writeln('Unknown value -> ', hex(floppy and $0F, 2));
  125.     Writeln;
  126.     caption3('Hard disk 0');
  127.     hd:=readCMOS($12);
  128.     hdc:=hd shr 4;
  129.     hdd:=hd and $0F;
  130.     if hdc = $F then
  131.       hdc:=readCMOS($19);
  132.     if hdd = $F then
  133.       hdd:=readCMOS($1A);
  134.     if hdc = 0 then
  135.       Writeln('None')
  136.     else
  137.       Writeln('Type ', hdc);
  138.     caption3('Hard disk 1');
  139.     if hdd = 0 then
  140.       Writeln('None')
  141.     else
  142.       Writeln('Type ', hdd);
  143.     Writeln;
  144.     caption3('Conventional RAM');
  145.     Writeln((word(256) * readCMOS($16)) + readCMOS($15):5, 'K');
  146.     caption3('    Extended RAM');
  147.     Writeln((word(256) * readCMOS($18)) + readCMOS($17):5, 'K');
  148.     Writeln;
  149.     caption3('CMOS checksum');
  150.     checksum1:=0;
  151.     for count:=$10 to $2D do
  152.       Inc(checksum1, readCMOS(count));
  153.     checksum2:=(word(256) * readCMOS($2E)) + readCMOS($2F);
  154.     if checksum1 = checksum2 then
  155.       Writeln('OK')
  156.     else
  157.       Writeln('Error!  Says ', hex(checksum2, 4), ' should be ', hex(checksum1, 4));
  158.     end
  159.   else
  160.     Writeln('No standard CMOS detected!!')
  161.   end;
  162.